#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long ret = 0;
    int left = 0, right = 0, lnum = 0;
    while (left < n)
    {
        while (right < n && a[right] - a[left] <= r) right++;
        while (lnum < n && a[lnum] - a[left] < l) lnum++;
        ret += right - lnum, left++;
    }
    cout << ret;
    return 0;
}